package thread.demo01.base;

import java.util.concurrent.atomic.AtomicInteger;

public class MyRunnable implements Runnable {

    private AtomicInteger atomicInteger = new AtomicInteger(100);

    @Override
    public void run() {
        while (atomicInteger.get() > 0) {
            int now = atomicInteger.decrementAndGet();
            System.out.println(Thread.currentThread().getName() + "---->" + now);
        }
    }

    public static void main(String[] args) {
        MyRunnable myRunnable = new MyRunnable();

        Thread thread = new Thread(myRunnable, "t1");
        Thread thread2 = new Thread(myRunnable, "t2");
        Thread thread3 = new Thread(myRunnable, "t3");
        thread.start();
        thread2.start();
        thread3.start();
    }
}
